﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using com.dz.components;
using com.dz.components.background;
namespace com.dz.winform
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        System.Threading.Thread t_thd_book = null;
        System.Threading.Thread t_thd_chapter = null;
        System.Threading.Thread t_thd_vip_chapter = null;
        System.Threading.Thread t_thd_shouda_chapter_asc = null;
        System.Threading.Thread t_thd_shouda_chapter_desc = null;
        System.Threading.Thread t_thd_uutxt_book = null;
        System.Threading.Thread t_thd_book_icon = null;
        private void button1_Click(object sender, EventArgs e)
        {
            CatchBaiDuVipManager t_baidu_mgr = new CatchBaiDuVipManager();
            CatchQiDianManager t_qidian_mgr = new CatchQiDianManager();
            
            if (t_chk_book.Checked)
            {
               
                t_thd_book = new System.Threading.Thread(t_qidian_mgr.StartCatchBook);
                t_thd_book.IsBackground = true;
                t_thd_book.Start();

            }
            if (t_chk_chapter.Checked)
            {
                t_thd_chapter = new System.Threading.Thread(t_qidian_mgr.StartCatchNormalChapter);

                t_thd_chapter.IsBackground = true;
                t_thd_chapter.Start();
            }

            if (t_chk_vip_chapter.Checked)
            {
                t_thd_vip_chapter = new System.Threading.Thread(t_baidu_mgr.StartCatchVipChpater);

                t_thd_vip_chapter.IsBackground = true;
                t_thd_vip_chapter.Start();
            }

            if (chk_shouda_chapter.Checked)
            {
                ShouDa8CatchManager t_shouda_mgr = new ShouDa8CatchManager();

                t_thd_shouda_chapter_asc = new System.Threading.Thread(t_shouda_mgr.StartCatchASC);

                t_thd_shouda_chapter_asc.IsBackground = true;
                t_thd_shouda_chapter_asc.Start();

                t_thd_shouda_chapter_desc = new System.Threading.Thread(t_shouda_mgr.StartCatchDESC);

                t_thd_shouda_chapter_desc.IsBackground = true;
                t_thd_shouda_chapter_desc.Start();
            }

            if (chk_icon.Checked)
            {
                BookICONCatchManager t_book_icon_mgr = new BookICONCatchManager();
                t_thd_book_icon = new System.Threading.Thread(t_book_icon_mgr.StartCatchICON);
                t_thd_book_icon.IsBackground = true;
                t_thd_book_icon.Start();
            }

            if (chk_uutxt.Checked)
            {

                UUTxtCatchManager t_uutxt_mgr = new UUTxtCatchManager();
                t_uutxt_mgr.StartCatchBook();

                //t_thd_uutxt_book = new System.Threading.Thread(t_uutxt_mgr.StartCatchBook);
                //t_thd_uutxt_book.IsBackground = true;
                //t_thd_uutxt_book.Start();
            }
        }

        private void Form2_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (t_thd_book != null)
            {
                t_thd_book.Abort();
            }

            if (t_thd_chapter != null)
            {
                t_thd_chapter.Abort();
            }

            if (t_thd_vip_chapter != null)
            {
                t_thd_vip_chapter.Abort();
            }

            if (t_thd_book_icon != null)
            {
                t_thd_book_icon.Abort();
            }
            if (t_thd_shouda_chapter_asc != null)
            {
                t_thd_shouda_chapter_asc.Abort();
            }
            if (t_thd_shouda_chapter_desc != null)
            {
                t_thd_shouda_chapter_desc.Abort();
            }
        }

       
    }
}